// Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
// This source file is part of the Cangjie project, licensed under Apache-2.0
// with Runtime Library Exception.
//
// See https://cangjie-lang.cn/pages/LICENSE for license information.

#ifndef CANGJIE_MIGRATOR_RULES_MATCH_RULE
#define CANGJIE_MIGRATOR_RULES_MATCH_RULE

#include <memory>
#include <string>

#include "Actions/Action.h"
#include "TomlFile.h"
#include "UpdateInstance.h"

namespace CangjieMigrator::Rules {

class Rule;
class ExtractedInfo;

class MatchRule {
public:
    enum class Type {
        All,
        CallExpr,
        MemberAccess,
        RefExpr,
        TypeName,
        LetAsPattern,
    };

    virtual ~MatchRule() = default;
    [[nodiscard]] virtual Type GetType() const = 0;
    virtual bool MatchConditions(const ExtractedInfo *info) = 0;
    virtual std::vector<Actions::Action> GenerateAction(
        UpdateInstance::File &file, const ExtractedInfo &info, const std::string &update, const Rule *rule) const = 0;

    static std::unique_ptr<MatchRule> TryCreate(const TomlConfig &config);
};

} // namespace CangjieMigrator::Rules

#endif // CANGJIE_MIGRATOR_RULES_MATCH_RULE